<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hammerspoon docs: MenubarFlag</title>
    <style type="text/css">
      a { text-decoration: none; }
      a:hover { text-decoration: underline; }
      th { background-color: #DDDDDD; vertical-align: top; padding: 3px; }
      td { width: 100%; background-color: #EEEEEE; vertical-align: top; padding: 3px; }
      table { width: 100% ; border: 1px solid #0; text-align: left; }
      section > table table td { width: 0; }
    </style>
    <link rel="stylesheet" href="docs.css" type="text/css" media="screen" />
  </head>
  <body>
    <header>
      <h1><a href="./index.html">docs</a> &raquo; MenubarFlag</h1>
      <p>Color the menubar according to the current keyboard layout</p>
<p>Download: <a href="https://github.com/Hammerspoon/Spoons/raw/master/Spoons/MenubarFlag.spoon.zip">https://github.com/Hammerspoon/Spoons/raw/master/Spoons/MenubarFlag.spoon.zip</a></p>
<p>Functionality inspired by <a href="https://pqrs.org/osx/ShowyEdge/index.html.en">ShowyEdge</a></p>

      </header>
      <h3>API Overview</h3>
      <ul>
        <li>Variables - Configurable values</li>
          <ul>
            <li><a href="#allScreens">allScreens</a></li>
            <li><a href="#colors">colors</a></li>
            <li><a href="#indicatorAlpha">indicatorAlpha</a></li>
            <li><a href="#indicatorHeight">indicatorHeight</a></li>
            <li><a href="#indicatorInAllSpaces">indicatorInAllSpaces</a></li>
            <li><a href="#timerFreq">timerFreq</a></li>
          </ul>
        <li>Methods - API calls which can only be made on an object returned by a constructor</li>
          <ul>
            <li><a href="#drawIndicators">drawIndicators</a></li>
            <li><a href="#getLayoutAndDrawindicators">getLayoutAndDrawindicators</a></li>
            <li><a href="#start">start</a></li>
            <li><a href="#stop">stop</a></li>
          </ul>
      </ul>
      <h3>API Documentation</h3>
        <h4 class="documentation-section">Variables</h4>
          <section id="allScreens">
            <a name="//apple_ref/cpp/Variable/allScreens" class="dashAnchor"></a>
            <h5><a href="#allScreens">allScreens</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag.allScreens</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Boolean to specify whether the indicators should be shown on all monitors or just the current one. Defaults to <code>true</code></p>
</td>
              </tr>
            </table>
          </section>
          <section id="colors">
            <a name="//apple_ref/cpp/Variable/colors" class="dashAnchor"></a>
            <h5><a href="#colors">colors</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag.colors</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Table that contains the configuration of indicator colors</p>
<p>The table below indicates the colors to use for a given keyboard
layout. The index is the name of the layout as it appears in the
input source menu. The value of each indicator is a table made of
an arbitrary number of segments, which will be distributed evenly
across the width of the screen. Each segment must be a valid
<code>hs.drawing.color</code> specification (most commonly, you should just
use the named colors from within the tables). If a layout is not
found, then the indicators are removed when that layout is active.</p>
<p>Indicator specs can be static flag-like:</p>

<pre><code>  Spanish = {col.green, col.white, col.red},
  German = {col.black, col.red, col.yellow},</code></pre>
<p>or complex, programmatically-generated:</p>

<pre><code>["U.S."] = (
   function() res={}
      for i = 0,10,1 do
         table.insert(res, col.blue)
         table.insert(res, col.white)
         table.insert(res, col.red)
      end
      return res
   end)()</code></pre>
<p>or solid colors:</p>

<pre><code>  Spanish = {col.red},
  German = {col.yellow},</code></pre>
<p>Contributions of indicator specs are welcome!</p>
</td>
              </tr>
            </table>
          </section>
          <section id="indicatorAlpha">
            <a name="//apple_ref/cpp/Variable/indicatorAlpha" class="dashAnchor"></a>
            <h5><a href="#indicatorAlpha">indicatorAlpha</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag.indicatorAlpha</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Number to specify the indicator transparency (0.0 - invisible; 1.0 - fully opaque). Defaults to 0.3</p>
</td>
              </tr>
            </table>
          </section>
          <section id="indicatorHeight">
            <a name="//apple_ref/cpp/Variable/indicatorHeight" class="dashAnchor"></a>
            <h5><a href="#indicatorHeight">indicatorHeight</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag.indicatorHeight</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Number to specify the height of the indicator. Specify 0.0-1.0 to specify a percentage of the height of the menu bar, larger values indicate a fixed height in pixels. Defaults to 1.0</p>
</td>
              </tr>
            </table>
          </section>
          <section id="indicatorInAllSpaces">
            <a name="//apple_ref/cpp/Variable/indicatorInAllSpaces" class="dashAnchor"></a>
            <h5><a href="#indicatorInAllSpaces">indicatorInAllSpaces</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag.indicatorInAllSpaces</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Boolean to specify whether the indicator should be shown in all spaces (this includes full-screen mode). Defaults to <code>true</code></p>
</td>
              </tr>
            </table>
          </section>
          <section id="timerFreq">
            <a name="//apple_ref/cpp/Variable/timerFreq" class="dashAnchor"></a>
            <h5><a href="#timerFreq">timerFreq</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag.timerFreq</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Number to indicate how frequently (in seconds) should the menubar indicator be updated. Defaults to 1.0.</p>
<p>Sometimes Hammerspoon misses the callback when the keyboard layout
changes. As a workaround, MenuBarFlag can automatically update the
indicator at a fixed frequency. The timer can be disabled by
setting this parameter to 0.</p>
</td>
              </tr>
            </table>
          </section>
        <h4 class="documentation-section">Methods</h4>
          <section id="drawIndicators">
            <a name="//apple_ref/cpp/Method/drawIndicators" class="dashAnchor"></a>
            <h5><a href="#drawIndicators">drawIndicators</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag:drawIndicators(src)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Draw the indicators corresponding to the given layout name</p>
<p>Parameters:</p>
<ul>
<li>src - name of the layout to draw. If the given element exists in <code>MenubarFlag.colors</code>, it will be drawn. If it does not exist, then the indicators will be removed from the screen.</li>
</ul>
<p>Returns:</p>
<ul>
<li>The MenubarFlag object</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="getLayoutAndDrawindicators">
            <a name="//apple_ref/cpp/Method/getLayoutAndDrawindicators" class="dashAnchor"></a>
            <h5><a href="#getLayoutAndDrawindicators">getLayoutAndDrawindicators</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag:getLayoutAndDrawindicators</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Draw indicators for the current keyboard method or layout</p>
<p>Parameters:</p>
<ul>
<li>None</li>
</ul>
<p>Returns:</p>
<ul>
<li>The MenubarFlag object</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="start">
            <a name="//apple_ref/cpp/Method/start" class="dashAnchor"></a>
            <h5><a href="#start">start</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag:start()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Start the keyboard layout watcher to draw the menubar indicators.</p>
</td>
              </tr>
            </table>
          </section>
          <section id="stop">
            <a name="//apple_ref/cpp/Method/stop" class="dashAnchor"></a>
            <h5><a href="#stop">stop</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>MenubarFlag:stop()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Remove indicators and stop the keyboard layout watcher</p>
</td>
              </tr>
            </table>
          </section>
  </body>
</html>